//背景控制脚本
cc.Class({
    extends: cc.Component,

    properties: {
        //背景滚动边界
        Bg_Max: cc.p(0,0),
        //背景重置边界
        Bg_Min: cc.p(0,0),
        //背景滚动速度
        Bg_Speed: {
            default: 0,
            visible: false,
        },
        //管理的背景子节点
        Bg_Child: {
            default: [],
            type: cc.Node
        }

    },

    onLoad () {
        //获取滚动速度
        this.Bg_Speed = Game.Self.Bg_Speed;

    },

    start () {

    },

    update (dt) {
        if(Game.End == true) {
            return;
        }
        this.Scroll_Func(this.Bg_Speed,dt);
    },

    //背景滚动方法
    Scroll_Func (speed,int) {
        var len = this.Bg_Child.length;
        for(var i = 0; i < len; i++) {
            if(this.Bg_Child[i].x - (speed * int) <= this.Bg_Max.x) {
                this.Bg_Child[i].x = this.Bg_Min.x;
            }
            this.Bg_Child[i].x -= speed * int;
        }
    },


});
